var path = require('path');
var webpack = require('webpack');

// var react = require("react");
// var reactDOM = require('react-dom');
var node_modules = path.resolve(__dirname, 'node_modules');
var pathToReact = path.resolve(node_modules, 'react/dist/react.min.js');
var pathToReactDOM = path.resolve(node_modules, 'react-dom/dist/react-dom.min.js');

var config = {
  entry: ['./src/app.tsx'],
     resolve: {
        alias: {
            "React": pathToReact,
            "react-dom": pathToReactDOM
        }
    },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'build')
  },
   module: {
      loaders: [
      {
        test: /\.tsx?$/,
        loader: "ts-loader",
        exclude: /node_modules/
      },
      {
      test: /\.jsx$/,
      loader: 'babel'
      }
    ]
  },
      externals: {
        "react": "React",
        "react-dom":"ReactDOM"
    },
   plugins: [
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ]
};

module.exports = config;